From 17f7fb9cd509e2d880687f8c9f806cdb9166203a Mon Sep 17 00:00:00 2001 From: robertlipe Date: Tue, 27 Jan 2015 03:40:52 +0000 Subject: [PATCH] Move rot13() to QString. --- gpsbabel/reference/gc/GCGCA8.gpx | 1 + gpsbabel/reference/gc/GCGCA8~html.txt | 1 + gpsbabel/reference/gc/GCGCA8~text-encoded.txt | 12 ++++++++ gpsbabel/reference/gc/GCGCA8~text.txt | 2 ++ gpsbabel/reference/gc/maggeo.gs | 2 +- gpsbabel/testo.d/text.test | 6 +++- gpsbabel/util.cc | 29 ++++++++----------- 7 files changed, 34 insertions(+), 19 deletions(-) create mode 100644 gpsbabel/reference/gc/GCGCA8~text-encoded.txt diff --git a/gpsbabel/reference/gc/GCGCA8.gpx b/gpsbabel/reference/gc/GCGCA8.gpx index c815350f9..146adb274 100644 --- a/gpsbabel/reference/gc/GCGCA8.gpx +++ b/gpsbabel/reference/gc/GCGCA8.gpx @@ -45,6 +45,7 @@ Now that it's intuitively obvious to even the most casual observer where the cac <br> <img SRC="http://www.mtgc.org/mtgc_member-banner.gif" WIDTH="500" HEIGHT="40" ALT="Member of Middle Tennessee GeoCachers Club [www.mtgc.org]" BORDER="0"></a></p> + There Is No Hint diff --git a/gpsbabel/reference/gc/GCGCA8~html.txt b/gpsbabel/reference/gc/GCGCA8~html.txt index 50b79a2c0..239c450d0 100644 --- a/gpsbabel/reference/gc/GCGCA8~html.txt +++ b/gpsbabel/reference/gc/GCGCA8~html.txt @@ -35,5 +35,6 @@ Unknown Cache / Unknown

Now that it's intuitively obvious to even the most casual observer where the cache is, turn on your geo-mojo and go find it.
Member of Middle Tennessee GeoCachers Club [www.mtgc.org]

+

Hint: There Is No Hint

diff --git a/gpsbabel/reference/gc/GCGCA8~text-encoded.txt b/gpsbabel/reference/gc/GCGCA8~text-encoded.txt new file mode 100644 index 000000000..dd439f55b --- /dev/null +++ b/gpsbabel/reference/gc/GCGCA8~text-encoded.txt @@ -0,0 +1,12 @@ +----------------------------------------------------------------------------- +GCGCA8 N35 55.300 W86 51.700 (16S 512480 3975269) +Oozy rat in a sanitary zoo by robertlipe - Unknown Cache / Unknown - (3 / 2) + +The cache is not at the coordinates above. These coords will get you to the correct park and within 1/2 mile of the cache. The cache is within 35 feet of the trail. It is not handicapped accessible. It is a nice walk in the woods that is practical for all ages. There is no space in the container for trading items. You should bring a writing stick and bug spray is recommended. + +So if the cache isn't at the above coordinates, where is it? Too bad I hid a boot Too hot to hoot Never odd or even Do geese see God? "Do nine men interpret?" "Nine men," I nod Rats live on no evil star Go hang a salami, I'm a lasagna hog Now that it's intuitively obvious to even the most casual observer where the cache is, turn on your geo-mojo and go find it. + [IMG] + +Hint: Gurer Vf Ab Uvag + +----------------------------------------------------------------------------- diff --git a/gpsbabel/reference/gc/GCGCA8~text.txt b/gpsbabel/reference/gc/GCGCA8~text.txt index 2ff60e87c..c742a7ba7 100644 --- a/gpsbabel/reference/gc/GCGCA8~text.txt +++ b/gpsbabel/reference/gc/GCGCA8~text.txt @@ -7,4 +7,6 @@ The cache is not at the coordinates above. These coords will get you to the co So if the cache isn't at the above coordinates, where is it? Too bad I hid a boot Too hot to hoot Never odd or even Do geese see God? "Do nine men interpret?" "Nine men," I nod Rats live on no evil star Go hang a salami, I'm a lasagna hog Now that it's intuitively obvious to even the most casual observer where the cache is, turn on your geo-mojo and go find it. [IMG] +Hint: There Is No Hint + ----------------------------------------------------------------------------- diff --git a/gpsbabel/reference/gc/maggeo.gs b/gpsbabel/reference/gc/maggeo.gs index 6bf5b8f57..dd89fbf7c 100644 --- a/gpsbabel/reference/gc/maggeo.gs +++ b/gpsbabel/reference/gc/maggeo.gs @@ -1,3 +1,3 @@ $PMGNGEO,4608.000,N,7300.000,W,0000,F,GC7FA4,Points godsiques,Sverdrup2,,Locationless (Reverse) Cache,1508102,1207105,1.0,1.0*7A -$PMGNGEO,3555.300,N,8651.700,W,0000,F,GCGCA8,Oozy rat in a sanita,robertlipe,,Mystery Cache,2906103,0307105,3.0,2.0*4A +$PMGNGEO,3555.300,N,8651.700,W,0000,F,GCGCA8,Oozy rat in a sanita,robertlipe,There Is No Hint,Mystery Cache,2906103,0307105,3.0,2.0*04 $PMGNCMD,END*3D diff --git a/gpsbabel/testo.d/text.test b/gpsbabel/testo.d/text.test index 0edef26c4..71ce40ebb 100644 --- a/gpsbabel/testo.d/text.test +++ b/gpsbabel/testo.d/text.test @@ -1,5 +1,9 @@ # Test HTML and Text output of a geocache. -gpsbabel -i gpx -f ${REFERENCE}/gc/GCGCA8.gpx -o html -F ${TMPDIR}/gc.html -o text -F ${TMPDIR}/gc.txt +gpsbabel -i gpx -f ${REFERENCE}/gc/GCGCA8.gpx \ + -o html -F ${TMPDIR}/gc.html \ + -o text -F ${TMPDIR}/gc.txt \ + -o text,encrypt -F ${TMPDIR}/gc-encoded.txt compare ${REFERENCE}/gc/GCGCA8~text.txt ${TMPDIR}/gc.txt +compare ${REFERENCE}/gc/GCGCA8~text-encoded.txt ${TMPDIR}/gc-encoded.txt compare ${REFERENCE}/gc/GCGCA8~html.txt ${TMPDIR}/gc.html diff --git a/gpsbabel/util.cc b/gpsbabel/util.cc index abb67520c..214fd1f59 100644 --- a/gpsbabel/util.cc +++ b/gpsbabel/util.cc @@ -1168,25 +1168,20 @@ strlower(char* src) QString rot13(const QString& s) { - char* result = xstrdup(s); - char* cur = result; - int flip = 1; - while (cur && *cur) { - if (flip) { - if (*cur == '[') { - flip = 0; - } else if (*cur >= 'A' && *cur <= 'Z') { - *cur = 'A' + ((*cur-'A')+13)%26; - } else if (*cur >= 'a' && *cur <= 'z') { - *cur = 'a' + ((*cur-'a')+13)%26; - } - } else if (*cur == ']') { - flip = 1; + static const QChar A('A'); + static const QChar M('M'); + static const QChar N('N'); + static const QChar Z('Z'); + QString r = s; + int i = r.length(); + while(i--) { + QChar letter = r[i].toUpper(); + if (letter >= A && letter <= M) { + r[i] = QChar(r[i].toLatin1() + 13); + } else if (letter >= N && letter <= Z) { + r[i] = QChar(r[i].toLatin1() - 13); } - cur++; } - QString r(result); - xfree(result); return r; } -- 2.30.2